package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonObject;
import com.ymatou.iapi.userservice.parameter.GetUserBillsRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.service.GetUserBillsRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*绑定邮箱Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserBillsRequestDto{
	private static GetUserBillsRequestDtoBean GetUserBillsRequestDtoBean;
	private static GetUserBillsRequestDtoCall GetUserBillsRequestDtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("绑定邮箱");
	}

	@Before
	public void caseUp() {
		GetUserBillsRequestDtoBean=new GetUserBillsRequestDtoBean();
		GetUserBillsRequestDtoCall=new GetUserBillsRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(GetUserBillsRequestDtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBillsRequestDto_001() {
		Logger.start(true,"uid查询用户信息,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			GetUserBillsRequestDtoBean.setUserId(uid);
			GetUserBillsRequestDtoCall.setData(GetUserBillsRequestDtoBean);
			GetUserBillsRequestDtoCall.callService();			
			Logger.verifyEquals("true", GetUserBillsRequestDtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", GetUserBillsRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			JsonObject result = GetUserBillsRequestDtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(cur.getLoginId(),result.get("LoginId").getAsString(),"验证LoginId");
			Logger.verifyEquals(cur.getMail(),result.get("LoginEmail").getAsString(),"验证LoginEmail");
			Logger.verifyEquals(cur.getMobile(),result.get("LoginMobile").getAsString(),"验证LoginMobile");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBillsRequestDto_002() {
		Logger.start(true,"loginid查询用户信息,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			GetUserBillsRequestDtoBean.setLoginId(cur.getLoginId());
			GetUserBillsRequestDtoCall.setData(GetUserBillsRequestDtoBean);
			GetUserBillsRequestDtoCall.callService();			
			Logger.verifyEquals("true", GetUserBillsRequestDtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", GetUserBillsRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			JsonObject result = GetUserBillsRequestDtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(cur.getLoginId(),result.get("LoginId").getAsString(),"验证LoginId");
			Logger.verifyEquals(cur.getMail(),result.get("LoginEmail").getAsString(),"验证LoginEmail");
			Logger.verifyEquals(cur.getMobile(),result.get("LoginMobile").getAsString(),"验证LoginMobile");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBillsRequestDto_003() {
		Logger.start(true,"查询用户信息包含登入密码,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			Thread.sleep(1000);
			GetUserBillsRequestDtoBean.setLoginId(cur.getLoginId());
			GetUserBillsRequestDtoBean.setIncludeLoginPas(true);
			GetUserBillsRequestDtoBean.setIncludeTps(true);
			GetUserBillsRequestDtoCall.setData(GetUserBillsRequestDtoBean);
			GetUserBillsRequestDtoCall.callService();			
			Logger.verifyEquals("true", GetUserBillsRequestDtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", GetUserBillsRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			JsonObject result = GetUserBillsRequestDtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(cur.getLoginId(),result.get("LoginId").getAsString(),"验证LoginId");
			Logger.verifyEquals(cur.getMail(),result.get("LoginEmail").getAsString(),"验证LoginEmail");
			Logger.verifyEquals(cur.getMobile(),result.get("LoginMobile").getAsString(),"验证LoginMobile");
			Logger.verifyNotNull(result.get("LoginPas").getAsString(),"验证LoginPas");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserBillsRequestDto_004() {
		Logger.start(true,"查询用户信息包含支付密码,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			JUserCallService.UpdateTradingPwd(uid, "abc123");
			Thread.sleep(1000);
			GetUserBillsRequestDtoBean.setLoginId(cur.getLoginId());
			GetUserBillsRequestDtoBean.setIncludeLoginPas(true);
			GetUserBillsRequestDtoBean.setIncludeTps(true);
			GetUserBillsRequestDtoCall.setData(GetUserBillsRequestDtoBean);
			GetUserBillsRequestDtoCall.callService();			
			Logger.verifyEquals("true", GetUserBillsRequestDtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", GetUserBillsRequestDtoCall.getString("ResponseCode"), "验证ResponseCode");
			JsonObject result = GetUserBillsRequestDtoCall.getJsonObject().get("Result").getAsJsonObject();
			Logger.verifyEquals(cur.getLoginId(),result.get("LoginId").getAsString(),"验证LoginId");
			Logger.verifyEquals(cur.getMail(),result.get("LoginEmail").getAsString(),"验证LoginEmail");
			Logger.verifyEquals(cur.getMobile(),result.get("LoginMobile").getAsString(),"验证LoginMobile");
			Logger.verifyNotNull(result.get("LoginPas").getAsString(),"验证LoginPas");
//			TradingPas
			Logger.verifyNotNull(result.get("TradingPas").getAsString(),"验证TradingPas");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}